Skip to content

Remove more pytz compat code + regression fixes - #1514

Merged
akx merged 1 commit into
python-babel:masterfrom
tomasr8:pytz
Nov 29, 2026
Merged

akx merged 1 commit into
python-babel:masterfrom
tomasr8:pytz

Conversation

@tomasr8

@tomasr8 tomasr8 commented Nov 28, 2026

Copy link
Copy Markdown
Member

A couple more cleanups + a regression fix following #1472

@tomasr8

tomasr8 commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Sorry for the various pings @akx I hope I'm not annoying you too much 😅 but I've apparently reached the 3 PR repo limit so I can only open this PR as a draft.. Any chance you can remove this rule for me? Thanks! ❤️

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.43%. Comparing base (394f91a) to head (7bdddc8).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1514   +/-   ##
=======================================
  Coverage   94.43%   94.43%           
=======================================
  Files          27       27           
  Lines        5051     5051           
=======================================
  Hits         4770     4770           
  Misses        281      281           
Flag Coverage Δ
macos-26-3.10 93.52% <100.00%> (ø)
macos-26-3.11 93.46% <100.00%> (ø)
macos-26-3.12 93.72% <100.00%> (ø)
macos-26-3.13 93.72% <100.00%> (ø)
macos-26-3.14 93.70% <100.00%> (ø)
macos-26-3.15 93.70% <100.00%> (ø)
macos-26-3.9 93.46% <100.00%> (ø)
macos-26-pypy3.11 93.42% <100.00%> (ø)
macos-26-pypy3.12 93.68% <100.00%> (ø)
ubuntu-24.04-3.10 93.54% <100.00%> (ø)
ubuntu-24.04-3.11 93.48% <100.00%> (ø)
ubuntu-24.04-3.12 93.74% <100.00%> (ø)
ubuntu-24.04-3.13 93.74% <100.00%> (ø)
ubuntu-24.04-3.14 93.72% <100.00%> (ø)
ubuntu-24.04-3.15 93.72% <100.00%> (ø)
ubuntu-24.04-3.9 93.48% <100.00%> (ø)
ubuntu-24.04-pypy3.11 93.44% <100.00%> (ø)
ubuntu-24.04-pypy3.12 93.70% <100.00%> (ø)
windows-2025-3.10 93.61% <100.00%> (ø)
windows-2025-3.11 93.55% <100.00%> (ø)
windows-2025-3.12 93.81% <100.00%> (ø)
windows-2025-3.13 93.81% <100.00%> (ø)
windows-2025-3.14 93.79% <100.00%> (ø)
windows-2025-3.15 93.79% <100.00%> (ø)
windows-2025-3.9 93.55% <100.00%> (ø)
windows-2025-pypy3.11 93.55% <100.00%> (ø)
windows-2025-pypy3.12 93.81% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Nov 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing tomasr8:pytz (7bdddc8) with master (394f91a)

Open in CodSpeed

Comment thread babel/dates.py
return zoneinfo.ZoneInfo(zone)
except zoneinfo.ZoneInfoNotFoundError as e:
except (zoneinfo.ZoneInfoNotFoundError, ValueError) as e:
# ValueError is raised for invalid zone names (e.g. absolute paths)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this in the other PR, I added a test for it.

Comment thread docs/dates.rst
>>> from babel.dates import _localize

>>> dt = _localize(tz, datetime(2007, 8, 15))
>>> dt = datetime(2007, 8, 15, tzinfo=tz)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_localize is now not used anywhere besides tests. Is it safe to move it there or do you think there's a chance someone is relying on it (despite being private)?

Comment thread tests/test_localtime.py
reason="Issue 1092 is not applicable on Windows",
)
def test_issue_1092(monkeypatch):
pytest.importorskip("pytz", reason="pytz is not installed")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not need pytz

@akx

akx commented Nov 28, 2026

Copy link
Copy Markdown
Member

@tomasr8 not at all! Added you to the allowlist.

@tomasr8

tomasr8 commented Nov 28, 2026

Copy link
Copy Markdown
Member Author

Awesome, thanks! :)

@tomasr8
tomasr8 marked this pull request as ready for review November 28, 2026 22:47
@akx
akx merged commit 01a8afa into python-babel:master Nov 29, 2026
36 checks passed
@tomasr8
tomasr8 deleted the pytz branch November 29, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants